<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\widgets\LinkPager;
use yii\helpers\Url;
use common\models\Order;
$this->params['breadcrumbs'][] = $this->title;

?>
  <div class="orderDetail">
  <div class="odMain">
    <div class="content-wrap">
      <div class="odCont">
        <h1 class="tt0">订单详情
          <span class="orderNumber">订单号：
            <em><?=Html::encode($order['id'])?></em>
          </span>
        </h1>
        <p class="txt positionr">
          <span class="waitPay"><?=Html::encode(Order::itemAlias('order_status',$order['order_status']))?></span>
          <span class="limitTime"><em><!-- 24小时23分 --></em><!-- 后订单将被关闭 --></span>
          <span class="btns" style="margin-top:-15px;">

            <?php if ($order['order_status'] == 1): ?>
              <a style="cursor:pointer" id="cancel" class="btn-small-empty">取消订单</a>
              <a href="/order/pay/<?=Html::encode($order['id'])?>" class="btn-small-default">立即付款</a>
            <?php endif ?>

          </span>
        </p>
        <div class="orderProgress">
          <div class="orderPro">
            <dl class="firstDl">
              <dt><span class="iconNumber inlineBlock">1</span></dt>
              <dd>提交订单</dd>

              <?php if ($order['order_status'] == 1): ?>
                <dd><?=Html::encode(date('Y-m-d H:i',strtotime($order['create_time'])))?></dd>
              <?php endif ?>
              
            </dl>
            <dl class="secondDl">
              <dt><span class="iconNumber inlineBlock">2</span></dt>
              <dd>付款成功</dd>
              <?php if ($order['order_status'] == 2): ?>
                <dd><?php //Html::encode(date('Y-m-d H:i',strtotime($order['update_time'])))?></dd>
              <?php endif ?>
            </dl>
            <dl class="thirdDl">
              <dt><span class="iconNumber inlineBlock">3</span></dt>
              <dd>已出库</dd>
              <?php if ($order['order_status'] == 3): ?>
                <dd><?php //Html::encode(date('Y-m-d H:i',strtotime($order['update_time'])))?></dd>
              <?php endif ?>
            </dl>
            <dl class="fourDl">
              <dt><span class="iconNumber inlineBlock">4</span></dt>
              <dd>已送达</dd>
              <?php if ($order['order_status'] == 4): ?>
                <dd><?php //Html::encode(date('Y-m-d H:i',strtotime($order['update_time'])))?></dd>
              <?php endif ?>
            </dl>
            <div class="proinner"></div>
          </div>
        </div>
        <div class="listInfo">
          <h1 class="tt0">商品清单</h1>
          <div class="goodsLists">
            <ul class="lists">

              <?php foreach ($order['list'] as $key => $v): ?>
                <li>
                  <img src="<?=Html::encode($v['img_url'])?>!s50x50" alt="" class="imge">
                  <p class="name">【<?=Html::encode($v['name'])?>】 <?=Html::encode($v['title'])?></p>
                  <span class="elem1">￥<?=Html::encode($v['price'].'x'.$v['product_num'])?></span>
                  <span class="elem2">￥<?=Html::encode($v['total_price'])?></span>
                </li>
              <?php endforeach ?>
              
            </ul>
            <p class="subInfo">
              <span class="elem1"><?=Html::encode($order['product_num'])?>件商品，总商品金额：</span>
              <span class="elem2">￥<?=Html::encode($v['total_price'])?></span>
            </p>
            <p class="subInfo">
              <span class="elem1">运费：</span>
                <span class="elem2">￥<?=Html::encode($order['shipping_fee'])?></span>
            </p>
            <p class="subInfo">
              <span class="elem1">应付总额：</span>
                <span class="elem2 total">￥<?=Html::encode($order['pay_fee'])?></span>
            </p>
          </div>
          <div class="consignee">
            <h1 class="tt0">收货人信息</h1>
            <ul class="detail">
              <li>
                <span class="tt">收货人：</span>
                <span><?=Html::encode($order['name'])?></span>
              </li>
              <li>
                <span class="tt">联系电话：</span>
                <span><?=Html::encode($order['phone'])?></span>
              </li>
              <li>
                <span class="tt">收货地址：</span>
                <span><?=Html::encode($order['province'].' '.$order['city'].' '.$order['district'].' '.$order['address_detail'])?></span>
              </li>
            </ul>
          </div>

          <div class="consignee">
            <h1 class="tt0">送货信息</h1>
            <ul class="detail">
              <li>
                <span class="tt">配货方式：</span>
                <span><?=Html::encode($order['shipping_id']?$order['shipping_id']:'平台配送')?></span>
              </li>
              <li>
                <span class="tt">送货时间：</span>
                <span></span>
              </li>
              <li>
                <span class="tt">订单附言：</span>
                <span><?=Html::encode($order['message'])?></span>
              </li>
            </ul>
          </div>

          <div class="consignee" style="display:none">
            <h1 class="tt0">发票信息</h1>
            <ul class="detail">
              <li>
                <span class="tt">需要发票：</span>
                <span>否</span>
              </li>
              <li>
                <span class="tt">发票抬头：</span>
                <span>阿斯顿发放</span>
              </li>
            </ul>
          </div>


        </div>
      </div>

    </div>
  </div>
    <div class="mask" style="display: none"></div>
    <div class="odPop" style="display: none">
      <p class="txt">确定要取消该订单吗？</p>
      <p class="btns"><a id="zbqx" class="btn-small-empty">暂不取消</a><a id="qdqx" class="btn-small-default">确定取消</a></p>
      <img src="http://static.tianpinwang.com.cn/v1/images/closeIcon1.png" alt="" class="close">
    </div>
</div>


<script>
  $(function(){

    //订单进度CSS
    var index = <?=Html::encode($order['order_status']-1)?>;
    $('.orderPro dl').eq(index).addClass('status');

    //取消订单
    $('#cancel').on('click',function(){
      var oid = <?=Html::encode($order['id'])?>;

      $('.mask').attr('style',"display:block");
      $('.odPop').attr('style',"display:block");
      $('#zbqx,.close').on('click',function(){
        $('.mask').attr('style',"display:none");
        $('.odPop').attr('style',"display:none");
      });

      $('#qdqx').on('click',function(){
        $('.mask').attr('style',"display:none");
        $('.odPop').attr('style',"display:none");
        var order_id = <?=Html::encode($order['id'])?>;
        $.post('/order/view',{'order_id':order_id,'_csrf':"<?=Yii::$app->request->getCsrfToken()?>"},function(data){
          if(data>0){
            layer.msg('取消成功！', {time: 1000}, function(){
              window.location.href = "";
            });
          }
        });
      });
    })

    function modifypro(){
      var $orderPro=$('.orderPro');
      var $proinner=$('.proinner');
      if($orderPro.children('dl').has('.status')){
        var $orderindex=$orderPro.children('.status').index();
        var $orderindex1=$orderindex+1;
        if($orderindex1==1){
          $proinner.css('width',680/6);
        }else if($orderindex1==2){
          $proinner.css('width',680/2);
        }else if($orderindex1==3){
          $proinner.css('width',680*5/6);
        }else if($orderindex1==4){
          $proinner.css('width','680px');
        }
      }
    }

    modifypro();

  })
</script>